package com.zen.demo.sys.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zen.demo.common.bean.R;
import com.zen.demo.sys.entity.Article;
import com.zen.demo.sys.entity.User;
import com.zen.demo.sys.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhengDing
 * @since 2022-01-27 22:39:30
 */
@RestController
@RequestMapping("/sys/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("save")
    public R save(@RequestBody Article article) {
        // if (article.getCreateById() != null && article.getCreateBy() != null) {
        //     if (article.getCreateBy().getId() != null) {
        //         article.setId(null);
        //     }
        // }
        return R.OK(articleService.saveOrUpdate(article));
    }

    @RequestMapping("list")
    public R list() {
        return R.OK(articleService.list());
    }

    @RequestMapping("page")
    public R page() {
        return R.OK(articleService.page(new Page<>(1, 10)));
    }
}
